//
//  YGSickCollectionViewCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/29.
//

#import "YGSickCollectionViewCell.h"

@interface YGSickCollectionViewCell ()
@property (nonatomic, strong) UIImageView  *coverImageView;
@property (nonatomic, strong) UILabel  *titleLabel;

@end
@implementation YGSickCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.coverImageView];
        [self addSubview:self.titleLabel];
        
        [self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(50);
            make.centerX.mas_equalTo(self);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(self);
            make.top.mas_equalTo(self.coverImageView.mas_bottom).offset(5);
            make.height.mas_equalTo(14);
        }];
    }
    return self;
}


- (void)configureModel:(YGSickListModel *)model{
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrl] completed:nil];
    self.titleLabel.text = model.name;
}

- (UIImageView *)coverImageView{
    if (!_coverImageView) {
        _coverImageView = [[UIImageView alloc] init];
    }
    return _coverImageView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:12];
        _titleLabel.textColor = UIColorFromRGB(0x333333);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}
@end
